﻿using BLL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace L20241019.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LoginController : ControllerBase
    {
        public LoginController(LoginBll bll)
        {
            Bll = bll;
        }

        public LoginBll Bll { get; }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="l">属性</param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public IActionResult AddLogin(Login l)
        {
            try
            {
                int res = Bll.AddLogin(l);
                return Ok(new
                {

                    data = res
                });

            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="Name">名字</param>
        /// <param name="Pwd">密码</param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public IActionResult LoginSelect(string Name, string Pwd)
        {
            try
            {
                var res = Bll.LoginSelect(Name, Pwd);
                return Ok(new
                {
                    data = res
                });

            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
